package com.demo.mvc.ioc;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class People003 {

  Animal animal;

//  @Autowired
//  public People003(  @Qualifier("dogImpl") Animal aAnimal){
//    animal = aAnimal;
//  }

  @Autowired
  public People003(  Animal[] animals){

    for(Animal animal : animals){
      log.info("test123,{}", animal.getClass());
      if (animal.getClass().getName().equals(CatImpl.class.getName()) ){
        this.animal= animal;
        break;
      }
    }
  }

  public void myAnimalSay(){
    animal.say();
  }
}
